﻿using System;

/*
 * Write a boolean expression that returns if the bit at position p (counting from 0) 
 * in a given integer number v has value of 1. Example: v=5; p=1  false.
 */

class IsACertainBit1
{
    static void Main(string[] args)
    {
        int v = 5;
        int p = 1;
        int mask = 1 << p;
        int paramaterAndMask = v & mask;
        bool isACertainBit1 = (paramaterAndMask >> p) == 1;
        String vBinary = Convert.ToString(v, 2).PadLeft(32, '0');
        Console.WriteLine("The bit in position {0} of {1} = {2} is 1: {3}", p, v, vBinary, isACertainBit1);
    }
}

